package code.rocky.consumer;

public class JoinTest1 {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + "  start ...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "  end ...");
        }, "t1");
        t1.start();
        Thread t2 = new Thread(() -> {
            synchronized (t1) {
                System.out.println(Thread.currentThread().getName() + "  start ...");
                try {
                    t1.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "  wakeup ...");

            }
        }, "t2");

        t2.start();
    }
}
